﻿/// <reference name="MicrosoftAjax.js"/>


Type.registerNamespace("com.eFORCE.AjaxControls");

com.eFORCE.AjaxControls.RollOverImageButton = function(element) {
    com.eFORCE.AjaxControls.RollOverImageButton.initializeBase(this, [element]);
    
    this._overImageUrl = null;
    this._imageUrl = null;
}

com.eFORCE.AjaxControls.RollOverImageButton.prototype = {
    initialize: function() {
        com.eFORCE.AjaxControls.RollOverImageButton.callBaseMethod(this, 'initialize');
        
        // Add custom initialization here
        this.onMouseOverHandler = Function.createDelegate(this, this._onMouseOver);
        this.onMouseOutHandler = Function.createDelegate(this, this._onMouseOut);
        
        //Add client event handlers here
        $addHandler( this.get_element(), 'mouseover', this.onMouseOverHandler );
        $addHandler( this.get_element(), 'mouseout', this.onMouseOutHandler );
        
        //set default image
        this.get_element().src = this._imageUrl;
    },
    dispose: function() {        
        //Add custom dispose actions here
        com.eFORCE.AjaxControls.RollOverImageButton.callBaseMethod(this, 'dispose');
    },
    _onMouseOver : function(e) {    //Event delegate
        //alert('this mouseover event');
        if (this.get_element())
        {
            this.get_element().src = this._overImageUrl;
        }
    },
    _onMouseOut : function(e) {     //Event delegate
        //alert('this mouseout event');
        if (this.get_element())
        {
            this.get_element().src = this._imageUrl;
        }
    },
    get_overImageUrl : function() {    //property : get_overImageUrl
        return this._overImageUrl;
    },
    set_overImageUrl : function(value) {   //property : set_overImageUrl
        if(this._overImageUrl !== value)
        {
            this._overImageUrl = value;
            this.raisePropertyChanged('overImageUrl');
        }
    },
    get_imageUrl : function() {      //property : get_imageUrl
        return this._imageUrl;
    },
    set_imageUrl : function(value) { //property : get_imageUrl
        if(this._imageUrl !== value)
        {
            this._imageUrl = value;
            this.raisePropertyChanged('imageUrl');
        }
    }
}

// Optional descriptor for JSON serialization.
com.eFORCE.AjaxControls.RollOverImageButton.descriptor =
{
    properties: [ {name: '_overImageUrl', type: String},
                  {name: '_imageUrl', type: String} ]
}

com.eFORCE.AjaxControls.RollOverImageButton.registerClass(
        'com.eFORCE.AjaxControls.RollOverImageButton', 
        Sys.UI.Control);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();